package miHaYou;

import java.util.Scanner;

public class Main1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();//层数
        in.nextLine();

        char[] arr = in.nextLine().toCharArray();

        long res = compute(arr,0);
        System.out.println(res%1000000007);
    }

    public static long compute(char[] arr,int rootIndex){
        int len = arr.length;
        int leftChild = rootIndex*2+1;
        int rightChild = rootIndex*2+2;

        //如果是叶子结点
        if(leftChild>=len){
            return 1;
        }else {
            /**
             * 非叶子结点，是左右两根节点的乘积，
             * 再乘 根据子结点的值看，相同为1，不同为2
             */
            boolean x = (arr[leftChild] == arr[rightChild]);
            return compute(arr,leftChild)*compute(arr,rightChild)*(x?1:2);
        }
    }
}
